<template>
  <div>
    <div class="demo-input-suffix gl_searchBox">
      <el-row :gutter="20">
        <el-col :span="4">
          <p>申报名称</p>
          <el-input v-model="qo.DuanExamName" placeholder="请输入申报名称" size="mini" clearable @change="getPageList()" />
        </el-col>
        <el-col :span="4">
          <p>申报机构</p>
          <el-input v-model="qo.OrganizationUnitName" placeholder="请输入申报机构" size="mini" clearable @change="getPageList()" />
        </el-col>
        <el-col :span="4">
          <p>考试地点</p>
          <el-input v-model="qo.Address" placeholder="请输入考试地点" size="mini" clearable @change="getPageList()" />
        </el-col>
        <el-col :span="4">
          <p>申报人</p>
          <el-input v-model="qo.Contact" placeholder="请输入申报人" size="mini" clearable @change="getPageList()" />
        </el-col>
        <el-col :span="6">
          <p>申报时间</p>
          <el-date-picker
            v-model="chooseTime"
            size="mini"
            type="daterange"
            style="width:100%"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="handleTimeChange"
          />
        </el-col>
        <el-col :span="4" class="search_btn" align="left">
          <!-- 查询按钮 -->
          <el-button type="primary" size="mini" @click="getPageList()">筛选</el-button>
          <!-- 重置按钮 -->
          <el-button type="warning" size="mini" @click="clickReset()">{{ $t('button.Reset') }}</el-button>
        </el-col>
      </el-row>
    </div>
    <el-table v-loading="tableLoading" :data="tableData" class="gl_table_noBorder gl_mt_15" size="mini" style="width: 100%;">
      <el-table-column label="序号" type="index" align="center" />
      <el-table-column label="申报名称" prop="duanExamName" min-width="120" />
      <el-table-column label="申报机构" prop="organizationUnitName" min-width="120" />
      <el-table-column label="考试地点" prop="address" min-width="140" />
      <el-table-column label="申报人数" prop="studentNumber" min-width="80" />
      <el-table-column label="申报金额" prop="requestAmount">
        <template slot-scope="{row}">
          {{ (row.requestAmount === 0 || row.requestAmount > 0) ? (row.requestAmount / 100).toFixed(2) : '' }}
        </template>
      </el-table-column>
      <el-table-column label="会员费" prop="memberAmount">
        <template slot-scope="{row}">
          {{ (row.memberAmount === 0 || row.memberAmount > 0) ? (row.memberAmount / 100).toFixed(2) : '' }}
        </template>
      </el-table-column>
      <el-table-column label="其他费用" prop="otherAmount">
        <template slot-scope="{row}">
          {{ (row.otherAmount === 0 || row.otherAmount > 0) ? (row.otherAmount / 100).toFixed(2) : '' }}
        </template>
      </el-table-column>
      <el-table-column label="总金额" prop="amount">
        <template slot-scope="{row}">
          {{ (row.amount === 0 || row.amount > 0) ? (row.amount / 100).toFixed(2) : '' }}
        </template>
      </el-table-column>
      <el-table-column label="申报人" prop="contact" min-width="70" />
      <el-table-column label="联系电话" prop="phoneNumber" :min-width="100" />
      <el-table-column label="申报时间" min-width="140">
        <template slot-scope="{row}">
          <span v-if="row.duanExamCreationTime">
            {{ row.duanExamCreationTime | FormatDate('yyyy-MM-dd HH:mm:ss') }}
          </span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="80">
        <template slot-scope="{ row }">
          <el-button size="mini" type="text" @click="toResultReview(row)">查看成绩</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row class="gl_pt_15" style="text-align: right;">
      <el-pagination
        :current-page="qo.Page"
        :page-size="qo.MaxResultCount"
        :total="total"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 30, 40]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>

<script>
import { Api_GET_ClubDuanExamStudentScoreExamReportQO } from '@/lib/form/hall/swaggerForm';
import { api_GET_ClubDuanExamStudentScoreExamReport } from '@/extend/api/hallswaggerApi/app';
export default {
  data() {
    return {
      chooseTime: [],
      qo: new Api_GET_ClubDuanExamStudentScoreExamReportQO(),
      tableLoading: false,
      total: 0,
      tableData: []
    };
  },
  created() {
    this.getPageList();
  },
  methods: {
    getPageList(page) {
      this.qo.Page = page || 1;
      this.qo.SkipCount = (this.qo.Page - 1) * this.qo.MaxResultCount;
      this.qo.sorting = 'duanExamCreationTime DESC';
      this.tableLoading = true;
      api_GET_ClubDuanExamStudentScoreExamReport(this.qo).then(res => {
        this.tableLoading = false;
        this.tableData = res.items;
        this.total = res.totalCount;
      }, error => {
        this.tableLoading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    },
    clickReset() {
      this.qo = new Api_GET_ClubDuanExamStudentScoreExamReportQO();
      this.chooseTime = [];
      this.getPageList();
    },
    handleTimeChange(time) {
      this.qo.StartTime = time ? time[0] + ' 00:00:00' : null;
      this.qo.EndTime = time ? time[1] + ' 23:59:59' : null;
      this.getPageList();
    },
    toResultReview(row) {
      this.$router.push({
        name: 'ResultReview',
        query: {
          type: 'result',
          id: row.duanExamId,
          name: row.duanExamName,
          no: row.placeNo
        }
      });
    },
    // 获取静态文件
    getStaticFileUrl(relativeUrl) {
      if (!relativeUrl) return '';
      return WEB_CONFIG.VUE_APP_STATIC_FILE_RUL + relativeUrl;
    },
    // 分页
    sizeChange(MaxResultCount) {
      this.qo.MaxResultCount = MaxResultCount;
      this.getPageList();
    },
    pageIndexChange(currentPage) {
      this.getPageList(currentPage);
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
